package edu.gdkm.demo7;

import java.io.FileNotFoundException;
import java.util.Scanner;

public class Calculator {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Scanner in = new Scanner(System.in);
		while (true) {
			System.out.println("请选择你需要计算的功能：");
			System.out.println("0.退出");
			System.out.println("1.除法计算");
			System.out.println("2.进制换算");
			System.out.println("3.圆计算");
			System.out.print("你选择的功能是：");

			int num = in.nextInt();
			if (num == 0) {
				System.out.println("谢谢使用，再见！");
				System.exit(0);
			}
			if (num == 1) {
				System.out.println("请使用‘a/b’的形式输入计算式");
				String str = scanner.nextLine();
				int k = str.indexOf('/');
				if (k > 0) {
					String a=str.substring(0, k);
					String b=str.substring(k + 1);
					Division.d(a,b);
				}
			}
			if (num == 2) {
				System.out.println("请使用‘a,b’的形式输入计算式");
				String str = scanner.nextLine();
				int k = str.indexOf(',');
				if (k > 0) {
					String a=str.substring(0, k);
					String b=str.substring(k + 1);
					try {
						Conversion.conversion(a,b);
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					}
				}
			}
		if (num == 3) {
			System.out.println("请使用‘r’的形式输入计算式");
			String r = scanner.nextLine();
			try {
				Circle.compute(r);
			} catch (Circle.RadiusException e) {

				e.printStackTrace();   //stack 栈
			}


		}
		}
	}
}
